package com.cn.shchuangge.cachemanger;

import java.io.IOException;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by 赵航 on 2017/6/7.
 */

public class HttpManger {
    private static final HttpManger ourInstance = new HttpManger();

    public static HttpManger getInstance() {
        return ourInstance;
    }

    private HttpManger() {
    }


    public String getData(String url) {

        try {
            OkHttpClient okHttpClient = new OkHttpClient.Builder().build();
            //同步请求
            Request request=new Request.Builder()
                    .url(url)
                    .build();

            Response response = okHttpClient.newCall(request).execute();

            String string = response.body().string();

            return string;
        } catch (IOException e) {
            e.printStackTrace();
            return null;//错误直接但会null、

        }


    }
}
